/*
 ============================================================================
 Page	     : 292
 Name        : sum_arr1.c
 Date	     : 20210405
 Author      : Hbue 18060333
 Copyright   : Your copyright notice
 Description : 数组元素之和
 	 	 	   如果编译器不支持%zd, 用%u或%lu替换它
 ============================================================================
 */

#include <stdio.h>
#define SIZE 10

int sum(int array[], int n);

int main(void)
{
	int marbles[SIZE] = { 20, 10, 5, 39, 4, 16, 19, 26, 31, 20 };
	long answer = 0;

	answer = sum(marbles, SIZE);
	printf("The total number of marbles is %ld.\n", answer);
	printf("The size of marbles is %zd bytes.\n", sizeof marbles);

	return 0;
}

int sum(int array[], int n)		// 这个数组的大小是?
{
	int total = 0;
	for(int i = 0; i < n; i++)
	{
		total += array[i];
	}
	printf("The size of array is %zd bytes.\n", sizeof array);

	return total;
}

